const {app, BrowserWindow} = require('electron')
const path = require('path')
const { contextIsolated } = require('process')

let mainWindow

app.whenReady().then(()=>{
    createWindow()
})

function createWindow() {
    const width =  800
    const height = 600
    mainWindow = new BrowserWindow({ 
        width, 
        height,
        webPreferences: {
            // nodeIntegration:true, // 开启node.js环境,不安全，不建议开启
            // contextIsolation: false // 关闭上下文隔离,preload.js与index.html共享window对象等
            preload:path.join(__dirname,'../preload/preload.js'), // 用preload执行node api
            sandbox:false // 渲染进程开启沙箱模式，关闭，preload.js可以访问electron 渲染进程API

        }
    
    })
    mainWindow.loadFile(path.join(__dirname,'../renderer/index.html'))
}


